#include "core/tensor_data_test.h"
#include "core/tensor_data.h"
#include "core/tensor_view.h"
#include "log.h"

namespace  ldl
{
namespace core
{
void TensorDataTest::test()
{
    // 初始化列表构造
    {
        TensorData<float> matrix = {
            {1.0f, 2.0f, 3.0f},
            {4.0f, 5.0f, 6.0f}
        };
        LogInfo() << "matrix: " << matrix;
        LogInfo() << "matrix.ndim(): " << matrix.ndim();
    }

    // shape + data构造
    {
        auto tensor_data = TensorData<float>({2,3}, {2,3,4,5,6,7});
        LogInfo() << "tensor_data: " << tensor_data;
    }

    // 子张量赋值
    {
        auto tensor_data = TensorData<float>({2,3}, {2,3,4,5,6,7});
        auto sub_tensor = TensorData<float>({3}, {8,9,10});

        tensor_data[0] = sub_tensor;
        LogInfo() << "tensor_data: " << tensor_data;
        LogInfo() << "sub_tensor: " << sub_tensor;
    }
}
}
}